﻿Imports System.Data.OleDb
Public Class ViewGuide
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Request.Params("GuideCreator") = "" Then
            Response.Redirect("~/Account/Login.aspx")
        End If
        myHeading.InnerHtml = Request.Params("GuideCreator") + "'s Guide"

        If IsPostBack = False Then
            'Count activity
            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BeachConnectionString").ConnectionString)
            Dim SqlString As String = "INSERT INTO SiteActivity(Activity) VALUES (@f1)"
            Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
            cmd.CommandType = CommandType.Text
            cmd.Parameters.AddWithValue("@f1", "Guides")
            oleDbConn.Open()
            cmd.ExecuteNonQuery()
            oleDbConn.Close()
        End If

    End Sub

    Protected Sub SqlDataSource1_Selected(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Selected
        'If datasource is empty
        If (e.AffectedRows < 1) Then
            myHeading.InnerHtml = "No Beach found"
        End If
        If (e.AffectedRows < 13) Then
            DataPagerBeaches.Visible = False
        Else
            DataPagerBeaches.Visible = True
        End If
    End Sub

    Protected Sub ListView1_DataBound(sender As Object, e As EventArgs)
        'Display datapager only if there is more than one page to display
        DataPagerBeaches.Visible = (DataPagerBeaches.PageSize < DataPagerBeaches.TotalRowCount)
    End Sub
End Class